# $Id: PKGBUILD 70155 2012-04-30 21:14:08Z bgyorgy $
# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=screenlets-pack-basic
_pkgname=indiv-screenlets
pkgver=0.1.6
pkgrel=2
pkgdesc="Desktop widgets for Screenlets"
arch=('any')
url="http://screenlets.org/"
license=('GPL3')
depends=('screenlets')
makedepends=('dos2unix')
optdepends=('python2-feedparser: Clear Rss Screenlet'
            'python2-pytz: Freemeteo Weather Screenlet'
            'python-imaging: Lipik Screenlet'
            'python2-numpy: Lipik Screenlet')
source=(https://launchpad.net/indiv-screenlets/trunk/$pkgver/+download/$_pkgname-$pkgver.tar.bz2
        drop-gnomevfs.patch)
md5sums=('d908308a60eecbee13a21917d36b10bc'
         '0ee366b0eafea6b646a7a5f02df2a65c')

build() {
  cd "$srcdir/$_pkgname-$pkgver"

  # Remove python2-gnomevfs dependency
  # https://code.launchpad.net/~ballogy/indiv-screenlets/lyrics-replace-gnomevfs/+merge/104175
  patch -Np1 -i "$srcdir/drop-gnomevfs.patch"

  # Some files are distributed in DOS format...
  find . -name \*.py -exec dos2unix -q '{}' \;

  # Python2 fix
  find . -name \*.py -exec sed -i 's@^#.*python$@#!/usr/bin/python2@' '{}' \;
  sed -i 's@^#.*python$@#!/usr/bin/python2@' src/Lyrics/gui/{ls_widget,afv_widgets}
  sed -i 's/python -u/python2 -u/' setup.py

  # Fix desktop files
  sed -i 's/desktop_file % (podir, packname, podir, podir)/desktop_file % (podir, normal_packname, podir, podir)/' setup.py
}

package() {
  cd "$srcdir/$_pkgname-$pkgver"

  python2 setup.py install --root=$pkgdir/ --optimize=1

  # Remove screenlets-pack-all, because a lot of them are broken
  rm "$pkgdir"/usr/lib/python2.7/site-packages/screenlets_pack_all-$pkgver-py2.7.egg-info
  rm -r "$pkgdir"/usr/share/applications/screenlets_pack_all
  rm -r "$pkgdir"/usr/share/screenlets/screenlets-pack-all
}
